<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="webtag" uri="http://www.iflexsys.tagslib.com.vn"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<html>
<head>
<title>Thông tin giỏ hàng</title>
</head>
<body>
	<div class="list-view">
		<div class="pr-head">
			<span class="pr-detail-name">Giỏ hàng của bạn</span>
		</div>
		<div class="height100">
			<form id="viewTransaction" action="view-transaction" method="GET">
				<input type="hidden" id="pageIndexId" name="pageIndex" value="1">
			</form>
			<table id="rounded-corner" class="responstable">
				<thead>
					<tr>
						<th scope="col" class="rounded-company"></th>
						<th scope="col" class="rounded">Sách</th>
						<th scope="col" class="rounded">Loại Sách</th>
						<th scope="col" class="rounded">Tác giả</th>
						<th scope="col" class="rounded">Nhà xuất bản</th>
						<th scope="col" class="rounded">Giá tiền</th>
						<th scope="col" class="rounded-q4">Thời gian</th>
					</tr>
				</thead>
				<c:choose>
					<c:when test="${empty transactions}">
						<tfoot>
							<tr>
								<td colspan="8" align="center">Giỏ hàng của bạn đang trống
								</td>
							</tr>
						</tfoot>
					</c:when>
					<c:otherwise>
						<tbody>
							<c:forEach var="transaction" items="${transactions}">
								<tr>
									<td>
									<c:choose>
											<c:when test="${transaction.audioBookId > 0 && not empty transaction.audioBookId}">
												<img src="getAudioImage?id=${transaction.audioBookId}" class="imgBook">
											</c:when>
											<c:otherwise>
												<img src="getBookImage?bookId=${transaction.bookId}" class="imgBook">
											</c:otherwise>
										</c:choose>
									</td>
									<td>${transaction.bookName}</td>
									<td>
										<c:choose>
											<c:when test="${transaction.audioBookId > 0 && not empty transaction.audioBookId}">
												Audio
											</c:when>
											<c:otherwise>
												Ebook
											</c:otherwise>
										</c:choose>
									</td>
									<td>${transaction.author}</td>
									<td>${transaction.publisherName}</td>
									<td>${transaction.totalPrice}</td>
									<td><fmt:formatDate value="${transaction.transactionDate}"
											pattern="dd-MM-yyyy HH:mm:ss" /></td>
								</tr>
							</c:forEach>
						<tbody>
					</c:otherwise>
				</c:choose>
			</table>

			<c:if test="${fn:length(transactions) > 0}">
				<div class="pagination">
					<webtag:pagination pagingInfo="${pagingInfo}"
						pageIndexId="pageIndexId" formId="viewTransaction" />
				</div>
			</c:if>
		</div>
	</div>
</body>
</html>